package utwente.hmi.touchmol;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Point;

import javax.swing.BorderFactory;
import javax.swing.border.Border;

import utwente.hmi.touchmol.elements.*;

import com.merl.diamondtouch.DtlibInputTframe;

/**
 * @author Jeroen Logtenberg
 */
public class DefaultGUI extends TouchMolGUI {

	private static final long serialVersionUID = 1L;
	
	@Override
	/**
	 * Checks if the user touches the molpanel or the bookmark panel.
	 */
	int determineLocation(int userID, DtlibInputTframe dtInputFrame) {
		Point center = calculateCenter(touchRect(dtInputFrame));
		
		if(jmolView.panelTouched(center)){
			return LOCATION_MOLPANEL;
		 }
		 else {
			return LOCATION_SCREENSHOTPANEL;
		 }
	}

	@Override
	/**
	 * The default GUI is made up of a molpanel, accompanied by a 
	 * vertical sidebar with the bookmark panel.
	 */
	void makeLayout() {
		
		SCALE = 4;
		
		//Cover SCALE-2 part of the screen, plus the part that the control bar covers.
		int molpanelSize = (displayWidth / SCALE * (SCALE - 1));
		
		jmolView = new MolPanel(molpanelSize,displayHeight);

		if (!PDBfile.equals(""))
			jmolView.loadPDB(PDBfile);

		screens = new ScreenshotPanel((displayWidth / SCALE) - 2, displayHeight);

		getContentPane().setLayout(new BorderLayout(1,0));
		getContentPane().add(jmolView, BorderLayout.CENTER);
		getContentPane().add(screens, BorderLayout.EAST);
		
		Border line = BorderFactory.createLineBorder(Color.white);
		screens.setBorder(line);
		screens.setIgnoreRepaint(true);

	}

	@Override
	public void releaseTurn(UserButton user) {
		
	}

	@Override
	public void requestTurn(UserButton user) {
		
	}

	@Override
	public void takeTurn(UserButton user) {
		
	}
}
